<template>
    <div class="container">
      <div class="header">
        <i class="el-icon-collection"></i>
        <span>查询统计</span>
      </div>
      <div class="content">
        <div class="left">
          <div class="item" v-for="(item, index) in items" :key="index"
               :class="{ 'selected': selectedItem === item }" @click="selectItem(item)"
               :style="{ backgroundImage: 'url(' + require('../../assets/images/' + item.imgName) + ')' }">
               <div class="item-content">
            {{ item.text }}
          </div>
          </div>
        </div>
        <div class="right">
          <component :is="selectedItem.component"></component>
        </div>
        <!-- <div class="footer">
          <div style="margin-top: 20px">
            <el-button @click="selectAll">选择全部</el-button>
            <el-button @click="inverseSelection">反向选择</el-button>
            <el-button @click="toggleSelection()">清楚选择</el-button>
            <el-button @click="toggleSelection()">删除所选</el-button>
          </div>
          <div class="block">
            <span class="demonstration"></span>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
                layout="total, sizes, prev, pager, next, jumper" :total="400">
            </el-pagination>
          </div>
        </div> -->
      </div>
    </div>
  </template>
  
  <script>
  import experProcedure from "./experimental-procedure/index.vue"
  import samplingPoints from "./sampling-points/index.vue"
  import newSequence from "./new-sequence/index.vue"
  
  export default {
    name: "sampleProcess",
    components: {
      experProcedure,
      samplingPoints,
      newSequence
    },
    data() {
      return {
        items: [
          { text: "采集点", imgName: "caiyangdian.png", component: "samplingPoints" },
          { text: "实验流程", imgName: "shiyanliucheng.png", component: "experProcedure" },
          { text: "重建序列", imgName: "chongjianxulie.png", component: "newSequence" },
        ],
        selectedItem: null,
        currentPage4:2,
      };
    },
    created() {
      this.selectedItem = this.items[0]; // 在组件创建时设置默认选择
    },
    methods: {
      selectItem(item) {
        this.selectedItem = item;
      },
      selectAll() {
        this.$refs.multipleTable.toggleAllSelection();
      },
      inverseSelection() {
        this.tableData.forEach((item) => {
          this.$refs.multipleTable.toggleRowSelection(item);
        });
      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach((row) => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      handleEdit(index, row) {
        console.log("Editing row:", index, row);
        this.$prompt("请输入新的名称:", row.protime, {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        })
        .then(({ value }) => {
          row.protime = value; // 更新名称字段
          this.$message({
            type: "success",
            message: "编辑成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "编辑取消",
          });
        });
      },
      handleDelete(index, row) {
        console.log("Deleting row:", index, row);
        this.$confirm("确定删除此行数据吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          this.tableData.splice(index, 1);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除取消",
          });
        });
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
    },
  };
  </script>
  
  <style scoped>
  .container {
  background: #fff;
  margin-top: 1.5rem;
}

.header {
  height: 4rem;
  display: flex;
  align-items: center;
  padding-left: 1rem;
  color: rgb(7, 46, 82);
  font-size: 24px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.content {
  display: flex;
  margin: 2rem;
  border: 1px solid #eceaeaea;
  padding: 1rem;
}

.left {
  width: 5%;
  display: flex;
  flex-direction: column;
  margin-left: 1%;
}

.right {
  width: 95%;
  padding-left: 1rem;
}

.item {
  background-size: 60%; /* 缩小背景图片 */
  background-position: center top; /* 背景图片居中并偏上 */
  background-repeat: no-repeat;
  width: 100px; /* 宽度设置为100px */
  height: 100px; /* 高度增加，为文字留出空间 */
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between; /* 调整项目在容器中的分布 */
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 20px;
  background-color: #CCCCCC;
  transition: border 0.3s, background-color 0.3s; /* 过渡效果 */
  position: relative;
}

.item-content {
  width: 100%;
  text-align: center;
  color: white; /* 文字颜色设置为白色 */
  font-size: 18px;
  margin-top: 70px;
}

.item.selected {
  border: 2px solid #409EFF; /* 为选中状态设置边框颜色 */
  background-color: #409EFF; /* 为选中状态设置背景色 */
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.block {
  display: flex;
  gap: 16px;
  margin-top: 20px;
}

.el-button {
  border-radius: 5px;
}

.el-button--primary {
  border-radius: 5px;
}
  </style>